from django.urls import path ,re_path
from users import views
urlpatterns = [
    # 登录
    # 设置 name='register' 用来路由重定向, 绑定前段界面 , 使其在改变路由的情况下 , 相应正确
    path('register/' , views.RegisterView.as_view() , name='register'),

    # 注册
    path('login/' , views.LoginView.as_view() , name='login'),

    # 校验用户名
    # 使用正则匹配js发送到的ajax请求 -- '/username/'+ this.username +'/count/'获得username , 进行路由检验
    re_path('^username/(?P<username>[A-Za-z0-9_]{5,15})/count/$' , views.UsernameCount.as_view()),

    # 退出
    path('logout/' , views.LogoutView.as_view() , name = 'logout'),

    # 用户中心
    path('user_info_center/' , views.UserInfoCenterView.as_view() , name = "user_info_center"),

    # 邮箱保存
    path('email/' , views.EmailView.as_view() ),

    # 验证邮箱
    path('verification/' , views.VerifyEmailView.as_view() ),

    # 设置收货地址
    path('user_center_site/', views.AddressView.as_view() , name = 'user_center_site'),

    # 修改密码
    path('user_center_pass/' , views.ChangePasswordView.as_view() , name = 'user_center_pass'),

    # 新增收货地址
    path('addresses/create/' , views.SaveAddressView.as_view() , name = 'address'),

    # 修改/删除地址 '/addresses/' + this.addresses[index].id + '/title/';
    re_path('^addresses/(?P<address_id>\d+)/$' , views.UpdataAddressView.as_view()),

    # 设置用户默认地址
    re_path('^addresses/(?P<address_id>\d+)/default/$' , views.DefaultAddressView.as_view()),

    # 用户浏览记录
    path('browse_histories/' , views.BrowseHistoriesView.as_view() , name = 'browse_histories'),

    # 用户订单
    path('user_order/' , views.UserOrderView.as_view() , name = 'user_center_order')

]